<template>
	<div class="bookshelf">
		<book v-for="item in infos" 
		:info="item" 
		:bookid="item.id" 
		type="find"></book>
	</div>
</template>
<script>
	import Book from './Book'
	import {getBookTitle} from './../../js/functions'
	import {updateTitle} from './../../vuex/action'
	import {getBookList} from './../../js/data'

	export default {
		data: function () {
			return {
				infos: []
			}
		},
		components: {
			Book
		},
		vuex: {
			actions: {
				updateTitle
			}
		},
		route: {
			activate: function () {
				// 获取当前路由的type属性
				let type = this.$route.params.type
				if (getBookTitle(type)) {
					// 更新title
					this.updateTitle(getBookTitle(type))
				}
				this.infos = getBookList(type)
			}
		}
	}
</script>
